package site.zhanjingbo.course;

import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Application {
	public static void main(String[] args) {
		//加载spring的配置文件，创建容器
		ApplicationContext applicationContext = new ClassPathXmlApplicationContext("application-context.xml");
		//通过Bean的id来对FileWriterService进行注入
		FileWirterService fileWriterService = applicationContext.getBean("fileWriterService",FileWirterService.class);
		//调用业务逻辑
		fileWriterService.write("Hello World");
		//关闭容器
		((ConfigurableApplicationContext)applicationContext).close();
	}
}
